package com.nicefact.mailmonitor.vo;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

import org.apache.commons.lang.StringUtils;

public class SearchBean {

	private String type;
	
	private Date dateFrom;
	
	private Date dateTo;
	
	private String searchStr;
	
	private boolean advanceSearch = false;
	
	private boolean unapprovedSearch = false;

	public boolean getAdvanceSearch() {
		return advanceSearch;
	}

	public void setAdvanceSearch(boolean advanceSearch) {
		this.advanceSearch = advanceSearch;
	}

	public boolean isUnapprovedSearch() {
		return unapprovedSearch;
	}

	public void setUnapprovedSearch(boolean unapprovedSearch) {
		this.unapprovedSearch = unapprovedSearch;
	}

	public String getType() {
		return type;
	}

	public void setType(String type) {
		this.type = type;
	}

	public Date getDateFrom() {
		return dateFrom;
	}

	public void setDateFrom(Date dateFrom) {
		this.dateFrom = dateFrom;
	}
	
	public void setDateFrom(String dateFromStr) {
		if(!StringUtils.isEmpty(dateFromStr)){
		SimpleDateFormat fromatter = new SimpleDateFormat("yyyy/MM/dd");
		try {
			this.dateFrom = fromatter.parse(dateFromStr);
		} catch (ParseException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		}else{
			this.dateFrom= new Date(Long.MIN_VALUE);
		}
	}

	public Date getDateTo() {
		return dateTo;
	}

	public void setDateTo(Date dateTo) {
		this.dateTo = dateTo;
	}
	
	public void setDateTo(String dateToStr) {
		if(!StringUtils.isEmpty(dateToStr)){
		SimpleDateFormat fromatter = new SimpleDateFormat("yyyy/MM/dd");
		try {
			this.dateTo = fromatter.parse(dateToStr);
		} catch (ParseException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}}else{
			this.dateTo= new Date(Long.MAX_VALUE);
		}
	}

	public String getSearchStr() {
		return searchStr;
	}

	public void setSearchStr(String searchStr) {
		this.searchStr = searchStr;
	}
	
	
}
